using UnityEngine;
using System;
using UnityEngine.UI;
using TMPro;

public class TipPanel : MonoBehaviour
{
    public TMP_Text tmpTip;
    public Button confirmBtn;
    public TMP_Text tmpConfirm;

    private static TipPanel panel;

    private void Awake()
    {
        panel = this;
        gameObject.SetActive(false);
    }

    public void ShowTipInMono(string tip, string confirm, Action onConfirm)
    {
        tmpTip.text = tip;
        tmpConfirm.text = confirm;
        confirmBtn.onClick.RemoveAllListeners();
        confirmBtn.onClick.AddListener(() =>
        {
            onConfirm?.Invoke();
            gameObject.SetActive(false);
        });
        gameObject.SetActive(true);
    }

    public static void ShowTip(string tip, string confirm, Action onConfirm)
    {
        panel.ShowTipInMono(tip, confirm, onConfirm);
    }
}
